var socket = new WebSocket('wss://' + window.location.hostname + ':8443');

// socket.on('message', function (msg) {
//     console.log("msg", msg);
//     $("#content").append($("<div>").text(msg));
// });

async function pageReady() {
    console.log("pageReady");
    const configuration = {
        'iceServers': [
            { 'urls': 'stun:stun.stunprotocol.org:3478' },
            { 'urls': 'stun:stun.l.google.com:19302' }
        ]
    }

    
    const peerConnection = new RTCPeerConnection(configuration);
    const offer = await peerConnection.createOffer();
    await peerConnection.setLocalDescription(offer);


    // peerConnection.onconnectionstatechange = event => {
    //     console.log("connectionstatechange", peerConnection.connectionState);
    //     if (peerConnection.connectionState === 'connected') {
    //         console.log("connected");
    //     }
    // }
}

function pageshow2() {
    var peerConnectionConfig = {
        'iceServers': [
            { 'urls': 'stun:stun.stunprotocol.org:3478' },
            { 'urls': 'stun:stun.l.google.com:19302' },
        ]
    };
    var peerConnection = new RTCPeerConnection(peerConnectionConfig);

    peerConnection.createOffer().then((description) => {
        console.log(description);
    }).catch((err) => {
        console.log(err);
    });
}